#ifndef __BUFSOCKET_H__

#define __BUFSOCKET_H__


class CBufSocket : public CObject 
	{
	friend class CMySocket;

	private:
		enum { BufSize = 2048 } ;
		unsigned char SendBuf[BufSize], RecvBuf[BufSize];
		int SendBufPos, RecvBufPos;
		CString Adr;
		int Port;
		int LastErr;
		CString DebugLog;
		CMySocket *Sock;

	public:
		CBufSocket();
		virtual ~CBufSocket();
		void SetAdress(CString& AAdr, int APort);
		void Send(const unsigned char* Data, int Count);
		int Receive(unsigned char* Data, int Max);
		int ReceiveCount() { return RecvBufPos; } ;
		virtual void ReceiveNotifier() { } ; // nur Platzhalter, falls Bedarf
		void Close();
		int GetLastError() { return LastErr; } ;
		CString GetDebugLog() { return DebugLog; } ;

	private:
		void FlushSendBuf();
		void AddLog(CString Msg, int Val = 0);

	} ;


#endif //def __BUFSOCKET_H__